<?php
include_once("db.inc");
$page = $_REQUEST["page"];
$type = $_REQUEST["type"];
$row_number = 10;
$start = $row_number*$page;
if($type==1)
$sql = "select tendoanhnghiep,taikhoan,date_format(ngaythamgia,'%d-%m-%X') as ngaythamgia from thanhvien limit $start,$row_number"; 
else
if($type==2)
{
$Keyword = $_REQUEST["Keyword"];
$sql = "select tendoanhnghiep,taikhoan,date_format(ngaythamgia,'%d-%m-%X') as ngaythamgia from thanhvien where tendoanhnghiep like '%$Keyword%' limit $start,$row_number"; 
}
$result = mysql_query($sql);
$return = "";
$return = $return."<table border=\"0\" cellpadding=\"1\" width=\"100%\">
<tr id=\"tr\">
<td align=\"center\" style=\"cursor:pointer; width:78%\"><b>Tên doanh nghiệp</b></td>
<td align=\"center\" style=\"cursor:pointer\"><b>Ngày tham gia</b></td>
</tr>";
$n = 0;
while ($row = mysql_fetch_array($result))
{
	$n++;
	$TenDoanhNghiep = $row["tendoanhnghiep"];
	$TaiKhoan = $row["taikhoan"];	
	$NgayThamGia = $row["ngaythamgia"];
     //hiển thị ra trình duyệt
    $return =  $return."<tr";
	if($n%2==0) $return = $return." bgcolor='#EEEEEE'";
	$return = $return.">
    <td height=\"34px\" style=\"cursor:pointer\" onclick=\"showSanPham(2,0,'$TaiKhoan')\">$TenDoanhNghiep</td>
    <td height=\"34px\" style=\"cursor:pointer\">$NgayThamGia</td>
    <td height=\"34px\" style=\"cursor:pointer; background:#FFFFFF\"><a href=\"http://www.google.com/search?q=$TenDoanhNghiep\"><img src=\"images/icon/Google.png\"/></a></td>	
    </tr>";
}
$return = $return."</table>";
$sql = "select * from thanhvien";
if(mysql_num_rows(mysql_query($sql))%$row_number == 0)
	$page_number = mysql_num_rows(mysql_query($sql))/$row_number;
	else $page_number = floor(mysql_num_rows(mysql_query($sql))/$row_number)+1;
if($page_number > 1)
{
	$return = $return."<p style=\"text-align:center\">";
	if($page != 0)
		$return = $return."<img src=\"images/prev2.png\" onclick=\"showDoanhNghiep(0)\" style=\"cursor:pointer\">&nbsp;&nbsp;";
	if($page != 0)
		$return = $return."<img src=\"images/prev.png\" onclick=\"showDoanhNghiep($page-1)\" style=\"cursor:pointer\">&nbsp;&nbsp;";
	for($i = 0; $i < $page_number; ++$i)
	{
		if($i == $page)
		$return = $return."<b onclick=\"showDoanhNghiep($i)\" style=\"cursor:pointer;color:#F00\" class=\"textPage\">".($i+1)."&nbsp;</b>";
		else $return = $return."<b onclick=\"showDoanhNghiep($i)\" style=\"cursor:pointer\" class=\"textPage\">".($i+1)."&nbsp;</b>";
	}
	if($page != $page_number-1)
		$return = $return."<img src=\"images/next.png\" onclick=\"showDoanhNghiep($page+1)\" style=\"cursor:pointer\">&nbsp;&nbsp;";
	if($page != $page_number-1)
		$return = $return."<img src=\"images/next2.png\" onclick=\"showDoanhNghiep($page_number-1)\" style=\"cursor:pointer\"></p>";
}
echo $return;
?>